package castleContent;

public class Castle {
	private static final int UNITS_UPGRADE_COST = 500;
	private static final int WIZZARD_COST = UNITS_UPGRADE_COST;
	private static final int ARCHER_COST = 300;
	private static final int BARBARIAN_COST = 150;
	private Barracks barracks;
	private ResourceBuilding goldMine;
	private ResourceBuilding foodFarm;

	Castle() {
		setBarracks(new Barracks());
		setFoodFarm(new ResourceBuilding());
		setGoldMine(new ResourceBuilding());

	}

	Castle(int gold, int goldProduction, int foodProduction, int food,
			int armyCapacity, int archers, int barbarians, int wizzards,
			int barbarianAd, int barbarianHp, int archerAd, int archerHp,
			int wizzardAd, int wizzardHp) {
		setGoldMine(new ResourceBuilding(gold, goldProduction));
		setFoodFarm(new ResourceBuilding(food, foodProduction));
		setBarracks(new Barracks(armyCapacity, archers, barbarians, wizzards,
				barbarianAd, barbarianHp, archerAd, archerHp, wizzardAd,
				wizzardHp));

	}

	public Barracks getBarracks() {
		return barracks;
	}

	private void setBarracks(Barracks barracks) {
		this.barracks = barracks;
	}

	public ResourceBuilding getGoldMine() {
		return goldMine;
	}

	private void setGoldMine(ResourceBuilding goldMine) {
		this.goldMine = goldMine;
	}

	public ResourceBuilding getFoodFarm() {
		return foodFarm;
	}

	private void setFoodFarm(ResourceBuilding foodFarm) {
		this.foodFarm = foodFarm;
	}

	// create Army
	public void crateBarbarian() {
		foodFarm.setAvailableResource(foodFarm.getAvailableResource()
				- BARBARIAN_COST);
		barracks.trainBarbarian(barracks.getBarbarianADLevel(),
				barracks.getBarbarianHPLevel());
	}

	public void crateAcher() {
		foodFarm.setAvailableResource(foodFarm.getAvailableResource()
				- ARCHER_COST);
		barracks.trainArcher(barracks.getArcherADLevel(),
				barracks.getArcherHPLevel());
	}

	public void crateWizzard() {
		foodFarm.setAvailableResource(foodFarm.getAvailableResource()
				- WIZZARD_COST);
		barracks.trainWizzard(barracks.getWizzardADLevel(),
				barracks.getWizzardHPLevel());
	}

	// upgrade Soldiers
	public void barbarianAdLevelUp() {
		goldMine.setAvailableResource(goldMine.getAvailableResource()
				- UNITS_UPGRADE_COST);
		barracks.upgradeBarbarianAD();
	}

	public void barbarianHpLevelUp() {
		goldMine.setAvailableResource(goldMine.getAvailableResource()
				- UNITS_UPGRADE_COST);
		barracks.upgradeBarbarianHP();
	}

	public void archerAdLevelUp() {
		goldMine.setAvailableResource(goldMine.getAvailableResource()
				- UNITS_UPGRADE_COST);
		barracks.upgradeArcherAD();
	}

	public void archerHpLevelUp() {
		goldMine.setAvailableResource(goldMine.getAvailableResource()
				- UNITS_UPGRADE_COST);
		barracks.upgradeArcherHP();
	}

	public void wizzardAdLevelUp() {
		goldMine.setAvailableResource(goldMine.getAvailableResource()
				- UNITS_UPGRADE_COST);
		barracks.upgradeWizzardAD();
	}

	public void wizzardHpLevelUp() {
		goldMine.setAvailableResource(goldMine.getAvailableResource()
				- UNITS_UPGRADE_COST);
		barracks.upgradeWizzardHP();
	}
}
